﻿package mortal.game.view.guild.otherpanel
{
    import Message.Game.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.pageSelect.*;
    import mortal.game.view.guild.cellrender.*;
    import mortal.mvc.interfaces.*;

    public class GuildInviteListPanel extends GuildOtherBasePanel
    {
        private var _pageSelecter:PageSelecter;
        private var _btnRejectAll:GButton;
        private var _inviteList:GTileList;
        private static const PAGE_MEMBER_COUNT:int = 10;
        private static var _instance:GuildInviteListPanel = null;

        public function GuildInviteListPanel(param1:ILayer = null)
        {
            super(param1);
            setSize(546, 402);
            title = "" + Language.getString(71184);
            return;
        }// end function

        override public function layoutUI() : void
        {
            UIFactory.bg(11.5, 30, 532.5, 26, this, ImagesConst.RegionTitleBg);
            UIFactory.gTextField(Language.getString(60046), 12, 34, 100, 20, this, GlobalStyle.textFormatPutong.center());
            UIFactory.gTextField(Language.getString(60058), 112, 34, 100, 20, this, GlobalStyle.textFormatPutong.center());
            UIFactory.gTextField(Language.getString(60060), 212, 34, 100, 20, this, GlobalStyle.textFormatPutong.center());
            UIFactory.gTextField(Language.getString(60073), 312, 34, 100, 20, this, GlobalStyle.textFormatPutong.center());
            UIFactory.gTextField(Language.getString(60033), 420, 34, 100, 20, this, GlobalStyle.textFormatPutong.center());
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.align = "center";
            this._pageSelecter = UIFactory.pageSelecter(215, 375, this, PageSelecter.CompleteMode);
            this._pageSelecter.setbgStlye(ImagesConst.ComboBg, _loc_1);
            this._pageSelecter.maxPage = 3;
            this._pageSelecter.currentPage = 1;
            this._pageSelecter.pageTextBoxSize = 45;
            this._pageSelecter.configEventListener(Event.CHANGE, this.onPageChange);
            this._btnRejectAll = UIFactory.gButton(Language.getString(60069), 375, 373, 64, 24, this);
            this._inviteList = UIFactory.tileList(13, 58, 530, 306, this);
            this._inviteList.rowHeight = 30.5;
            this._inviteList.columnWidth = 668;
            this._inviteList.horizontalGap = 1;
            this._inviteList.verticalGap = 0.5;
            this._inviteList.setStyle("cellRenderer", GuildInviteListCellRenderer);
            return;
        }// end function

        override public function update() : void
        {
            var _loc_5:int = 0;
            var _loc_6:SPlayerInviteInfo = null;
            var _loc_1:* = Cache.instance.guild.inviteList;
            this._pageSelecter.maxPage = Math.ceil(_loc_1.length / PAGE_MEMBER_COUNT);
            var _loc_2:* = (this._pageSelecter.currentPage - 1) * PAGE_MEMBER_COUNT;
            var _loc_3:* = new DataProvider();
            var _loc_4:int = 0;
            while (_loc_4 < PAGE_MEMBER_COUNT)
            {
                
                _loc_5 = _loc_2 + _loc_4;
                if (_loc_5 >= _loc_1.length)
                {
                    break;
                }
                _loc_6 = _loc_1[_loc_5];
                _loc_3.addItem(_loc_6);
                _loc_4++;
            }
            this._inviteList.dataProvider = _loc_3;
            this._inviteList.drawNow();
            return;
        }// end function

        override public function onMouseClick(event:MouseEvent) : void
        {
            switch(event.target)
            {
                case this._btnRejectAll:
                {
                    Cache.instance.guild.removeInviteInfo(0, true);
                    this.update();
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            this.update();
            return;
        }// end function

        public static function get instance() : GuildInviteListPanel
        {
            if (!_instance)
            {
                _instance = new GuildInviteListPanel;
            }
            return _instance;
        }// end function

    }
}
